<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css"/>
    <link rel="stylesheet" href="/static/css/bodymain.css">
    <link rel="stylesheet" href="/static/css/addArticle.css">
    <link rel="stylesheet" href="/static/css/home.css">
    <title>百知课程后台管理系统-修改文章</title>
    <script src="/static/js/jquery.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <script>
        function selectCourse(t) {
            let id = t.value
            $.ajax({
                type: 'get',
                url: '{% url "course:get_sub_categories" %}',
                data: {'id': id},
                success: function (resp) {
                    let cate_list = resp.cate_list
                    let bigString = ''
                    for (let i = 0; i < cate_list.length; i++) {
                        let cate = cate_list[i]
                        bigString += '<option value="' + cate.id + '" >' + cate.title + '</option>'
                    }
                    $(".my-sel:last").html(bigString)
                }
            })
        }

        function save() {
            document.forms[1].submit()
        }
    </script>
</head>
<body>
<nav class="navbar navbar-default nav-self">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">百知课程后台管理系统</a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="../user/login.html" role="button">登录 <span class="glyphicon glyphicon-log-in"></span></a>
                </li>
                <li>
                    <a href="../user/logout.html">退出 <span class="glyphicon glyphicon-log-out"></span></a>
                </li>
            </ul>
            <form class="navbar-form navbar-right">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="">
                </div>
                <div class="btn-group" role="group" aria-label="...">
                    <div class="btn-group" role="group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                aria-haspopup="true" aria-expanded="false">
                            <span class="glyphicon glyphicon-search"></span>
                        </button>
                    </div>
                </div>
            </form>

        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="panel-group col-sm-2 left-side-bar" id="accordion" role="tablist" aria-multiselectable="true">
            <div>
                <div class="panel panel-default">
                    <div class="panel-heading left-side-header">百知课程</div>
                    {% for cate in cate_list %}
                        <div class="course-python"><a
                                href="{% url 'course:article_list' %}?level=1&id={{ cate.id }}">{{ cate.title }}</a>
                        </div>
                        <div class="list-group">
                            {% for sub_cate in sub_cate_list %}
                                {% if sub_cate.parent_id == cate.id %}
                                    <a href="{% url 'course:article_list' %}?level=2&id={{ sub_cate.id }}"
                                       class="list-group-item">{{ sub_cate.title }}</a>
                                {% endif %}
                            {% endfor %}
                        </div>
                    {% endfor %}

                </div>
            </div>
        </div>
        <div class="tab-content col-sm-10 right-side">
            <form action="{% url 'course:update_article_logic' %}" method="post">
                {% csrf_token %}
                <input type="hidden" name="id" value="{{ art.id }}">
                <div class="panel panel-default right-side-content">
                    <div class="page-header">
                        <h3>修改文章</h3>
                    </div>
                    <table class="table table-bordered">
                        <tr>
                            <td align="center" valign="middle">文章名称：</td>
                            <td><input type="text" name="title" class="my-inp" value="{{ art.title }}"/></td>
                        </tr>
                        <tr>
                            <td align="center">所属课程/类别：</td>
                            <td>
                                <select name="course_sel" class="my-sel" onchange="selectCourse(this)">
                                    {% for cate in cate_list %}
                                        {% if art.cate.parent_id == cate.id %}
                                            <option value="{{ cate.id }}" selected>{{ cate.title }}</option>
                                        {% else %}
                                            <option value="{{ cate.id }}">{{ cate.title }}</option>
                                        {% endif %}
                                    {% endfor %}

                                </select>
                                <select name="cate_sel" class="my-sel">
                                    {% for special_cate in special_cate_list %}
                                        {% if art.cate.id == special_cate.id %}
                                            <option value="{{ special_cate.id }}"
                                                    selected>{{ special_cate.title }}</option>
                                        {% else %}
                                            <option value="{{ special_cate.id }}">{{ special_cate.title }}</option>
                                        {% endif %}
                                    {% endfor %}
                                </select>

                            </td>
                        </tr>
                        <tr>
                            <td align="center">文章内容：</td>
                            <td><textarea class="form-control" name="contents" rows="3">{{ art.contents }}</textarea></td>
                        </tr>
                    </table>
                    <div class="btn-toolbar" role="toolbar" aria-label="...">
                        <div class="btn-group" role="group" aria-label="...">
                            <button type="button" class="btn btn-default my-btn" onclick="save()"><span
                                    class="glyphicon glyphicon-floppy-disk"></span>
                                保存
                            </button>

                        </div>

                    </div>
                </div>
            </form>
        </div>
    </div>

</div>
<div class="footer">
    <div class="container">
        <div class="row">
            <div class="col-sm-4">
                <div class="thumbnail">
                    <div class="caption">
                        <h4><span class="glyphicon glyphicon-heart-empty glyphicon"></span> 关注我们</h4>
                        <p>最受欢迎的管理平台</p>
                        <p><a href="#" class="ic_df"> 新浪微博</a></p>
                        <p><a href="#" class="ic_weichat"> 官方微信</a></p>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="thumbnail">
                    <div class="caption">
                        <h4><span class="glyphicon glyphicon-king"> 开发平台</span></h4>
                        <p>加入开发平台，尊享会员福利，成为资深程序猿</p>
                        <p class="p_idea"><a href="http://www.baizhibest.com"
                                             class="btn btn-default btn-lg idea">我要开发</a></p>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="thumbnail">
                    <div class="caption">
                        <h4><span class="glyphicon glyphicon-phone-alt"></span> 关于我们</h4>
                        <p>欢迎反馈宝贵意见</p>
                        <p class="p_idea"><a href="http://www.baizhibest.com"
                                             class="btn btn-default btn-lg idea">意见反馈</a></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 cp_info">
                <div class="no-mp">
                    <p>CopyRight © 2020 北京百知教育科技有限公司 All Rights Reserved</p>
                    <p>电话：010-****888 京ICP备*******8号</p>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
